#ifndef NETCLIENT_H
#define NETCLIENT_H

#include <QObject>
#include <QNetworkAccessManager>

namespace netclient {

class NetClient : public QObject
{
    Q_OBJECT
public:
    NetClient(QObject *parent = nullptr);
    void hello();	// 发送hello请求
    void ping();	// ping请求

private:
    static QString makeRequeId();
    QNetworkReply* sendHttpRequest(const QString& resourcePath, QJsonObject& jsonBody);
    QJsonObject handleHttpResponse(QNetworkReply* httpResp, bool* ok, QString *reason);
private:
    const QString HTTP_URL = "http://127.0.0.1:8000";
    QNetworkAccessManager httpClient;
};

}	// end netclient
#endif // NETCLIENT_H
